package com.example.controller;

import com.example.pojo.MyProperties;
import com.example.pojo.MyProperties2;
import com.example.pojo.MyThing;
import com.example.pojo.User;
import com.example.service.HelloWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
public class HelloWorldController {

    @Autowired
    private HelloWorldService helloWorldService;

    @RequestMapping("/helloWorldService")
    public String helloWorldService() {
        return helloWorldService.helloWorld();
    }

    @Autowired
    private MyProperties myProperties;

    @Autowired
    private MyProperties2 myProperties2;

    @RequestMapping("/getMyProperties")
    public MyProperties getMyProperties() {
        return myProperties;
    }

    @RequestMapping("/getMyProperties2")
    public MyProperties2 getMyProperties2() {
        return myProperties2;
    }

    @RequestMapping("/getMyThing")
    public MyThing getMyThing() {
        log.trace("TRACE：调用getMyThing()方法");
        log.debug("DEBUG：调用getMyThing()方法");
        log.info("INFO：调用getMyThing()方法");
        log.warn("WARN：调用getMyThing()方法");
        log.error("ERROR：调用getMyThing()方法");
        return new MyThing("张三", 18);
    }

    @Value("${helloWorld}")
    private String helloWorld;

    @RequestMapping("/helloworld")
    public String helloWorld() {
        return helloWorld;
    }

    @RequestMapping("/getUser")
    public User getUser() {
    	return new User("张三", 18);
    }



}